from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token,ObtainJSONWebToken
from rest_framework.routers import DefaultRouter

urlpatterns = [

    #1,判断用户名是否存在
    url(r'^usernames/(?P<username>\w{5,20})/count/$',views.UsernameCount.as_view()),

    #2,判断手机号是否存在
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$',views.MobileCount.as_view()),

    #3,注册用户
    url(r"^$",views.RegisterUserView.as_view()),

    #4,用户登陆
    # url(r"^auths/$",obtain_jwt_token),
    url(r"^auths/$",views.UserObtainJSONWebToken.as_view()),

    #5,获取用户数据
    url(r'^infos/$',views.UserDetailView.as_view()),

    #6,发送邮件
    url(r'^emails/$',views.UserEmailView.as_view()),

    #7,校验邮件地址
    url(r'^emails/verification/$',views.UserEmailCheckView.as_view()),

    #8,记录用户的访问历史
    url(r'^browerhistories/$',views.UserBrowserHistoryView.as_view()),
    # 修改密码
    url(r'^(?P<pk>\d+)/password/$',views.ChangePasswordView.as_view()),
    # 手机号码以及图片验证码校验
    url(r'^accounts/(?P<mobile>1[3-9]\d{9})/sms/token/$', views.UserAccountView.as_view()),
    # 发送短信
    url(r'^sms_codes/$', views.UserAccountSMSView.as_view()),
    # 验证手机号，获取修改密码的access_token
    url(r'^accounts/(?P<mobile>1[3-9]\d{9})/password/token/$', views.UserAccountSMSVerifyView.as_view()),
    # 重置密码
    url(r'^(?P<pk>\d+)/passwords/$', views.UserAccountPasswordView.as_view()),

]

#1,创建router对象
router = DefaultRouter()

#2,注册视图集
router.register('addresses',views.UserAddressViewSet,base_name="address")

#3,添加路由到urlpatterns
urlpatterns += router.urls

# print(router.urls)